
public class Convert {
    
	public static long hexToLong(String h) {        		
			return Long.valueOf(h, 16).longValue();
    }

    public static String hexToBinary(String h) {
        long instruction = Long.valueOf(h, 16).longValue();
        String binInstruction = Long.toBinaryString(instruction);
        if (binInstruction.length() < 32) {
            binInstruction = stringOfChars('0', 32 - binInstruction.length())
                    + binInstruction;
        }
        return binInstruction;
    }

    public static String binaryToHex(String s) {
        long binOpcode = Integer.parseInt(s, 2);
        System.out.println(binOpcode);
        String hexOpCode = Long.toHexString(binOpcode);
        return hexOpCode;
    }

    public static int binaryToInteger(String s) {
        return Integer.parseInt(s, 2);
    }

    public static long binaryToLong(String s) {
        return Long.parseLong(s, 2);
    }

    public static String stringOfChars(char c, int count) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < count; i++) {
            sb.append(c);
        }
        return sb.toString();
    }
}
